<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<style>

</style>
<form:form commandName="project" cssClass="form-horizontal" role="form" onsubmit="return false;">

    <%--项目基本情况--%>
    <div class="form-group">
        <label class="col-sm-2 control-label no-padding-right">项目名称</label>
        <div class="col-sm-4">
            <input type="text" value="${project.name}" readonly="readonly"
                   class="form-control ">
        </div>
        <label class="col-sm-2 control-label no-padding-right">项目地址</label>
        <div class="col-sm-3">
            <input type="text" value="${project.address}" readonly="readonly"
                   class="form-control">
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label no-padding-right">责任单位</label>
        <div class="col-sm-4">
            <input type="text" value="${project.resDept}" readonly="readonly"
                   class="form-control">
        </div>
        <label class="col-sm-2 control-label no-padding-right">分管领导</label>
        <div class="col-sm-3">
            <input type="text" value="${project.resUser}" readonly="readonly"
                   class="form-control ">
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label no-padding-right">项目联系人</label>
        <div class="col-sm-4">
            <input type="text" value="${project.contactName}" readonly="readonly"
                   class="form-control ">
        </div>
        <label class="col-sm-2 control-label no-padding-right">联系人手机号</label>
        <div class="col-sm-3">
            <input type="text" value="${project.contactPhone}" readonly="readonly"
                   class="form-control">
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label no-padding-right">项目责任人</label>
        <div class="col-sm-4">
            <input type="text" value="${project.ownerUnitPerson}" readonly="readonly"
                   class="form-control ">
        </div>
        <label class="col-sm-2 control-label no-padding-right">责任人手机号</label>
        <div class="col-sm-3">
            <input type="text" value="${project.ownerUnitPersonPhone}" readonly="readonly"
                   class="form-control">
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label no-padding-right">项目类型</label>
        <div class="col-sm-4">
            <input type="text" value="${project.natureTypeDetail}" readonly="readonly"
                   class="form-control ">
        </div>
        <label class="col-sm-2 control-label no-padding-right">投资金额</label>
        <div class="col-sm-3">
            <input type="text" value="${project.money}万元" readonly="readonly"
                   class="form-control">
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-2 control-label no-padding-right">项目状态</label>
        <div class="col-sm-4">
            <input id = "statusInput" type="text" value="" readonly="readonly" class="form-control ">
        </div>
        <label class="col-sm-2 control-label no-padding-right">项目督查组</label>
        <div class="col-sm-3">
            <input type="text" value="${project.groupName}" readonly="readonly"
                   class="form-control">
        </div>
    </div>

    <hr width="100%;height:2px;" style="border-top: 1px solid #aaa; margin: 0;">
    <div class="form-group" id="superAuth" style="display: none">
        <div class="col-sm-2 pull-right">
            <button class="btn btn-large btn-primary" id="beginAndStop" data-id="${project.sysId}"></button>
        </div>
        <div class="col-sm-2 pull-right">
                <button class="btn btn-large btn-primary" id="editProject" data-id="${project.sysId}">修改项目</button>
        </div>
        <div class="col-sm-3 pull-right">
            <button class="btn btn-large btn-primary"
                    onclick="window.location.href='/projectManger/queryNode?sysId='+'${project.sysId}'">查看项目节点详情</button>
        </div>
    </div>
    <div class="form-group" id="commonAuth" style="display: none">
        <div class="col-sm-3 pull-right">
            <button class="btn btn-large btn-primary"
                    onclick="window.location.href='/projectManger/queryNode?sysId='+'${project.sysId}'">查看项目节点详情</button>
        </div>
    </div>

    <%--任务id  隐藏--%>
    <input type="text" id="branchType" value="${user.branchType}" style="display:none;">
</form:form>
<script type="text/javascript">
    var status = ${project.status};
    var statusCName;
    if (status == "2") {
        statusCName = "未审核(进行中)";
        $("#beginAndStop").html("暂停项目");
    } else if (status == "3") {
        statusCName = "审核通过(进行中)";
        $("#beginAndStop").html("暂停项目");
    } else if (status == "4") {
        statusCName = "项目已完成";
        $("#beginAndStop").html("暂停项目");
    } else if (status == "6") {
        statusCName = "项目已暂停";
        $("#beginAndStop").html("启动项目");
    } else {
        statusCName = "未确定";
        $("#beginAndStop").html("暂停项目");
    }
    $("#statusInput").val(statusCName);

    var branchType = $("#branchType").val();
    if (branchType == "2") {
        //超级权限
        $("#superAuth").css("display", "inline");
    } else{
        //普通权限
        $("#commonAuth").css("display", "inline");
    }
    /**
     * 下载
     */
    $(".downloadFile").click(function () {
        var id = $(this).data("id");
        var url = "/communal/download/" + id;
        window.open(url);
    });
    jQuery(function ($) {
        $('.date-picker').datepicker({
            inline: true,
            format: "yyyymmdd",
            autoclose: true,
            todayHighlight: true,
            language: 'cn'
        })
        //show datepicker when clicking on the icon
            .next().on(ace.click_event, function () {
            $(this).prev().focus();
        });
        $(".downloadFile").each(function () {
            if (isEmpty($(this).data("id"))) {
                $(this).attr("style", "display:none;");
            }
        });
    });

    //************************************修改项目************************************
    $("#editProject").click(function () {
        var projectId = $(this).data("id");//项目id
        loadDialog({
            dialogTitle: '修改项目',
            dialogUrl: baseUrl + "editProject/" + projectId,
            dialogFoot: '<button type="button" class="btn btn-info" data-dismiss="modal" onclick="editPro_back()">返回</button>' +
                '<button type="button" class="btn btn-danger" data-dismiss="modal" id="editPro">确认修改</button>' +
                '<button type="button" class="btn btn-default" data-dismiss="modal" >关闭</button>'
        });
    });

    //************************************暂停项目************************************
    $("#beginAndStop").click(function () {
        var title = $("#beginAndStop").html();
        var projectId = $(this).data("id");//项目id
        var win = confirm("温馨提示：确认"+title+"?");
        var url = "";
        if (win == true) {
            if (title == "暂停项目") {
                url = "/projectManger/pause";
                stopStart(projectId, url);
                //延时加载
                window.setTimeout(editPro_back, 500);
            } else if (title == "启动项目") {
                url = "/projectManger/start";
                stopStart(projectId, url);
                //延时加载
                window.setTimeout(editPro_back, 500);
            }
        }
    });


    // //修改——返回
    // function editPro_back() {
    //     var rowId = $('#gridTable').jqGrid('getGridParam', "selrow");
    //     // var rowData = $("#gridTable").jqGrid('getRowData', rowId);
    //     loadDialog({
    //         dialogTitle: '更多操作',
    //         dialogUrl: baseUrl + "detail/" + rowId,
    //         dialogFoot: '<button type="button" class="btn btn-default" data-dismiss="modal" id="showDetail" >关闭</button>'
    //     });
    // }

    /**
     *
     * @param id 项目id
     * @param url 请求路径
     */
    function stopStart(id, url) {
        console.log(url);
        $.ajax({
            type: "POST",
            url: url,
            dataType: "json",
            data: JSON.stringify({sysId: id}),
            contentType: 'application/json;charset=UTF-8',
            success: function (data) {
            }
        });
    }

</script>